package com.icez.designmode

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.widget.Button
import com.icez.indicator_view.IndicatorView
import com.icez.indicator_view.IndicatorViewAdapter

class MainActivity : AppCompatActivity() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_main)
        val indicatorView = findViewById<IndicatorView>(R.id.indicatorView)
        val btn = findViewById<Button>(R.id.btn)
        val list = ArrayList<String>()
        for(i in 0 until 6){
            list.add("")
        }
        indicatorView.setAdapter(object:IndicatorViewAdapter<String>(list){

            override fun getSelectedLayoutId(): Int {
                return R.layout.selected_layout
            }

            override fun getNormalLayoutId(): Int {
                return R.layout.normal_layout
            }

        })

        btn?.setOnClickListener {
            val rand = (0..4).random()
            Log.e("icez","random: ${rand}")
            indicatorView.setSelectPosition(rand)
        }
    }
}